<?php
namespace app\home\controller;
class Index extends Common{
	
    public function _initialize(){
        parent::_initialize();
    }
	
    public function index(){
		$user = db('users')->where('id', session('home_uid'))->find();
		$this->assign('user', $user);
		
		$fos_count = db('buy_list')->where(['m_id'=>session('home_uid'), 'status'=>2, 'is_end'=>0])->sum("count");
		$this->assign('count', $fos_count);
		
		
		$rule = db('rule')->order("id")->select();
		$rules = [];
		foreach($rule as $itm){
			$rules[$itm['level']] = $itm['earning'];
		}
		$earning = $rules["F".$user['level']];
		$worth = round($fos_count*2000 * $earning/100, 4);
		$this->assign('day_sy', $worth);
        return $this->fetch();
    }
	
	public function task(){
        return $this->fetch();
    }
}